#include<bits/stdc++.h>
using namespace std;
int sum[10000]={0},a[1010]= {0, 1},cnt=1;
//void chai(long long x);
int main()
{
	int n,i;
	long long t=1;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(int j = 1; j <= 1000; j++)
			a[j] *= i;
		for(int j = 1; j <= 1000; j++)
		{
			a[j+1] += a[j]/10;
			a[j] %= 10;
		}
		for(int j = 1; j <= 1000; j++)
			sum[j] += a[j]	;
		
	}
	for(int j=1;j<=1000;j++)
		{
			sum[j+1]+=sum[j]/10;
			sum[j]%=10;
		}
//	i=sum[cnt]>0?cnt:cnt-1;
	for(i=1000;i>=1 && a[i] == 0;i--);
	for(;i>=1;i--)
	cout<<sum[i];
    return 0;
}
